<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
</head>
<body>
    <!-- 
        原生JS绑定事件的方式有两种
        DOM0级：element.onXX=function(){}
        DOM2级: element.addEventListener(事件类型,function(){})
        vue中事件绑定的语法
        <元素 v-on:事件类型="回调函数">
        v-on简写形式: @事件类型="回调函数"
     -->
    <div id="root">
        <ul>
            <li v-for="item in list" :key="item.id">{{item.id}}---{{item.name}}----<input></li>
        </ul>
        <!-- <button v-on:click="addPerson">添加</button> -->
        <button @click="addPerson">添加</button>
    </div>
    <script>
        new Vue({
            el:'#root',
            data(){
                return{
                    list:[
                        {
                            id:'1001',
                            name:'张三'
                        },
                        {
                            id:'1002',
                            name:'李四'
                        }
                    ]
                }
            },
            methods: {
                addPerson(){
                   //this.list.push({id:'1003',name:'王五'})
                   this.list.unshift({id:'1003',name:'王五'})
                }
            },
        })
    </script>
</body>
</html>